package com.whmskj.xjlhsc.mobie.ProductionManagement.service.imp;

import cn.hutool.core.util.NumberUtil;
import com.whmskj.xjlhsc.mobie.ProductionManagement.mapper.ElectronicYarnClearerMapper;
import com.whmskj.xjlhsc.mobie.ProductionManagement.pojo.vo.ElectronicYarnClearerVO;
import com.whmskj.xjlhsc.mobie.ProductionManagement.service.IElectronicYarnClearerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author jiaruchun
 * @date 2025-08-25 13:53
 */
@Service
//@DataSource(DataSourceType.SC)
public class ElectronicYarnClearerServiceImpl implements IElectronicYarnClearerService {

    @Autowired
    private ElectronicYarnClearerMapper electronicYarnClearerMapper;

    @Override
    public List<ElectronicYarnClearerVO> getElectronicYarnClearerReport(Integer type) {
        //返回前面10天的数据
        List<ElectronicYarnClearerVO> last10DaysValues = electronicYarnClearerMapper.getLast10DaysValues(type);
        for (ElectronicYarnClearerVO last10DaysValue : last10DaysValues) {
            //乘以100,非0保留2位小数
            if(last10DaysValue.getValue()!=0){
                last10DaysValue.setValue(
                        NumberUtil.round(last10DaysValue.getValue(), 2).doubleValue()
                );
            }
        }
        return last10DaysValues;
    }
}
